package com.ticket.sass.admin.dto.output.douyin;

/**
 * @author ywb
 * @date 2024-07-19 11:22
 */

import com.ticket.sass.common.entity.tenant.DouyinGoodEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@ApiModel(value="DouyinGoodListOutput对象", description="商品列表输出数据")
public class DouyinGoodListOutput implements Serializable {
    
    @ApiModelProperty(value = "商品ID")
    private String productId;
    
    @ApiModelProperty(value = "商品名称")
    private String productName;
    
    @ApiModelProperty(value = "商品类型 1-团购 11-代金券 15-次卡")
    private Short productType;
    
    @ApiModelProperty(value = "在线状态 1-在线 2-下线 3-封禁")
    private Short onlineStatus;
    
    @ApiModelProperty(value = "售卖开始时间")
    private LocalDateTime soldStartTime;
    
    @ApiModelProperty(value = "售卖结束时间")
    private LocalDateTime soldEndTime;
    
    @ApiModelProperty(value = "是否允许核销")
    private Boolean redeemable;
    
    @ApiModelProperty(value = "备注")
    private String remark;
    
    
    public DouyinGoodListOutput(String productId, String productName, Short productType, Short onlineStatus,
                                LocalDateTime soldStartTime, LocalDateTime soldEndTime, Boolean redeemable,
                                String remark) {
        this.productId = productId;
        this.productName = productName;
        this.productType = productType;
        this.onlineStatus = onlineStatus;
        this.soldStartTime = soldStartTime;
        this.soldEndTime = soldEndTime;
        this.redeemable = redeemable;
        this.remark = remark;
    }
    
    // 默认构造函数
    public DouyinGoodListOutput() {}
    
    // 静态方法，将DouyinGoodEntity转换为DouyinGoodListOutput
    public static DouyinGoodListOutput fromEntity(DouyinGoodEntity entity) {
        if (entity == null) {
            return null; // 或者抛出一个异常，取决于你的业务需求
        }
        return new DouyinGoodListOutput(
            entity.getProductId(),
            entity.getProductName(),
            entity.getProductType() != null ? entity.getProductType().getValue() : null,
            entity.getOnlineStatus() != null ? entity.getOnlineStatus().getValue() : null,
            entity.getSoldStartTime(),
            entity.getSoldEndTime(),
            entity.isRedeemable(),
            entity.getRemark()
        );
    }
}
